﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Hashtable hashtable = new Hashtable();
            hashtable.Add(1,"烤腰子");
            hashtable.Add(2,"烤鸡翅");
            hashtable.Add(3,"烤鸭腿");
            hashtable.Add(4,"烤鸭脖");
            foreach (DictionaryEntry imem in hashtable)
            {
                int key = (int)imem.Key;
                string val = imem.Value.ToString();
                Console.WriteLine("菜的号码为：{0}，菜的名称为：{1}", key, val);
            }
            Console.WriteLine("请输入你想吃的菜的号码：");
            int id = int.Parse(Console.ReadLine());
            bool flag = hashtable.ContainsKey(id);
            Console.WriteLine("菜单如下：");
            
            if (flag)
            {
                Console.WriteLine("你查找的图书名称：{0}",hashtable[id].ToString());
            }
            else
            {
                Console.WriteLine("你查找的菜不存在！");
            }
        }
    }
}
